package controllers;

import play.*;
import play.mvc.*;

import java.util.*;

import models.*;

public class Application extends Controller {

    public static void index() {
    	List<Post> posts = Post.findAll();
        render(posts);
    }

    public static void saveComment(Long postId,String title,String content){
    	Post post = Post.findById(postId);
    	Comment comment = new Comment();
    	comment.post = post;
    	comment.title = title;
    	comment.content = content;
    	comment.save();
    	comment = comment.cloneForJSON();
    	renderJSON(comment);
    }
    
    public static void showPost(Long postId){
    	Post post = Post.findById(postId);
    	post = post.cloneForJSON();
    	render(post);
    }
}